<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改账号</title>
<link rel="stylesheet" href="../static/layui/css/layui.css">
<style>    
  .layui-body{ padding: 10px}
</style>
</head>
<body>
    </br>
	<h2>修改账号信息</h2></br>
	<c:forEach items="${apage}" var="stu">
	<!-- 主体内容区 lay-verify="required"必填项  -->
	<form class="layui-form" action="student?m=modify&id=${stu.user_id}" method="post">
	  <!-- 用户名 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">用户名</label>
	    <div class="layui-input-block">
	      <input type="text" name="user" required  lay-verify="required" value="${stu.user_name}" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	  <!-- 权限 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">权限</label>
	    <div class="layui-input-block">
	      <select name="limit" lay-verify="required">
	        <option value="${stu.role_id}">${stu.role_name}</option>
	        <c:forEach items="${roleList}" var="cls">
	        <c:if test="${cls.role_name!=null}">
	        <option value="${cls.role_id}">${cls.role_name}</option>
	        </c:if>
	        </c:forEach>
	      </select>
        </div>
      </div>
	  
	  <!-- 班级 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">班级</label>
	    <div class="layui-input-block">
	      <select name="classes" lay-verify="required">
	        <option value="${stu.class_id}">${stu.class_name}</option>
	        <c:forEach items="${classlist}" var="cls">
	        <c:if test="${cls.class_name!=null}">
	        <option value="${cls.class_id}">${cls.class_name}</option>
	        </c:if>
	        </c:forEach>
	      </select>
        </div>
      </div>
	  
	  <!-- 密码 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">密码框</label>
	    <div class="layui-input-inline">
	      <input type="password" name="password" required lay-verify="required" value="${stu.user_password}" autocomplete="off" class="layui-input">
	    </div>
	    <div class="layui-form-mid layui-word-aux">密码不能为空</div>
	  </div>
	  
	  <!-- 电话 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">电话</label>
	    <div class="layui-input-block">
	      <input type="text" name="phone" value="${stu.user_phone}" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	  <!-- 性别 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">性别</label>
	    <div class="layui-input-block">
	      <input type="radio" name="sex" value="男" title="男">
	      <input type="radio" name="sex" value="女" title="女" checked>
	    </div>
	  </div>
	  
	  <!-- 微信 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">微信</label>
	    <div class="layui-input-block">
	      <input type="text" name="weixin" value="${stu.user_wx}" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	  <!-- 描述 -->
	  <div class="layui-form-item layui-form-text">
	    <label class="layui-form-label">描述</label>
	    <div class="layui-input-block">
	      <textarea name="desc" value="${stu.user_desc}" class="layui-textarea"></textarea>
	    </div>
	  </div>
	  
	  <!-- 头像 -->
	  <div class="layui-form-item">
         <label class="layui-form-label">头像</label>
         <div class="layui-input-block">
             <input type="text" name="photo" id="test2" value="" style="display:none;"/>
             <button type="button" class="layui-btn" id="test1">
                 <i class="layui-icon"></i>上传图片
             </button>
         </div>
      </div>
	  
	  <!-- 提交 -->
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
	      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	    </div>
	  </div>
	</form>
	</c:forEach>
</body>
<script type="text/javascript" src="../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../static/layui/layui.js"></script>
<script>
//上传头像图片
layui.use('upload', function(){
  var upload = layui.upload;
   
  var uploadInst = upload.render({
	    elem: '#test1' //绑定元素
	    ,url: '../uploadImage' //上传接口
	    ,done: function(res){
	    	console.log(res);
            layui.$("#test2").attr('value', res.src);
            var v=$("#test2").attr('value');
            console.log(v);
            alert('上传成功');
	    }
	  });
});
//提交监听
layui.use('form', function(){
	  var form = layui.form;
	  
	  //监听提交
	  form.on('submit(formDemo)', function(data){
		  layer.msg('修改成功，学生管理可查看');
	    return true;
	  });
});
</script>
</html>